<template>
  <div style="padding: 15px;">
    <vxe-toolbar id="warehouseLocationId" :custom="{storage: true}" export :refresh="{query: findList}">
      <template v-slot:buttons>
        <el-button @click="findList">查询</el-button>
        <el-button :loading="exportAllloading" @click="AllDataEventAll">导出全部</el-button>
      </template>
    </vxe-toolbar>
    <vxe-table
      ref="xTable"
      border
      resizable
      stripe
      highlight-current-row
      :align="allAlign"
      show-footer
      highlight-hover-row
      row-id="id"
      class="mytable-footer"
      height="700"
      :loading="loading"
      :export-config='{type:"csv"}'
      :data="tableData"
      :edit-config="{trigger: 'click', mode: 'row', showStatus: true}"
      sort-config.remote
      @sort-change="sortList"
      auto-resize
      @checkbox-all="checkboxChangeEvent"
      @checkbox-change="checkboxChangeEvent"
      :seq-config="{startIndex: listQuery.pageNum * listQuery.pageSize - listQuery.pageSize}"
    >
      <vxe-table-column type="seq" width="60"></vxe-table-column>
      <vxe-table-column type="checkbox" width="60"></vxe-table-column>
      <vxe-table-column field="statusText" title="状态" min-width="150" sortable />
      <vxe-table-column>
        <vxe-table-column field="waybillPrintCount" title="打印次数" min-width="150" sortable />
        <template v-slot:header="{ column }">
          <el-input v-model="listQuery.waybillPrintCount" type='number' placeholder="打印次数" clearable />
        </template>
      </vxe-table-column>
      <vxe-table-column>
        <vxe-table-column
          field="prepackaged"
          title="是否预打包"
          min-width="150"
          sortable
          :formatter="formatterPackaged"
        />
        <template v-slot:header="{ column }">
          <el-select v-model="listQuery.prepackaged" placeholder="请选择" clearable>
            <el-option
              v-for="item in prepackagedList"
              :key="item.value"
              :label="item.label"
              :value="item.value"
            ></el-option>
          </el-select>
        </template>
      </vxe-table-column>
      <vxe-table-column>
        <vxe-table-column field="warehouseName" title="仓库" min-width="150" />
        <template v-slot:header="{ column }">
          <el-select v-model="listQuery.warehouseCode" placeholder="请选择所属仓库 " style="width:100%" clearable>
            <el-option
              v-for="item in warehouseData"
              :key="item.code"
              :label="item.name"
              :value="item.code"
            />
          </el-select>
        </template>
      </vxe-table-column>
      <vxe-table-column>
        <vxe-table-column field="shipmentName" title="入驻商" min-width="150" sortable/>
        <template v-slot:header="{ column }">
          <el-select v-model="listQuery.shipmentName" clearable filterable placeholder="请选择入驻商">
            <el-option
              v-for="item in options"
              :key="item.partyCode"
              :label="item.userName"
              :value="item.userName">
            </el-option>
          </el-select>
        </template>
      </vxe-table-column>
      <vxe-table-column>
        <vxe-table-column field="remarks" title="备注" min-width="180" sortable />
        <template v-slot:header="{ column }">
          <el-input v-model="listQuery.remarks" placeholder="备注" clearable />
        </template>
      </vxe-table-column>

      <vxe-table-column>
        <vxe-table-column
          field="carrierName"
          title="承运商"
          min-width="150"
          sortable
        />
        <template v-slot:header="{ column }">
          <el-select v-model="listQuery.carrierCode" clearable filterable placeholder="承运商">
            <el-option
              v-for="item in carrierList"
              :key="item.code"
              :label="item.name"
              :value="item.code">
            </el-option>
          </el-select>
        </template>
      </vxe-table-column>
       <vxe-table-column>
        <vxe-table-column field="waybillCode" title="面单号" min-width="150" sortable />
        <template v-slot:header="{ column }">
          <el-input v-model="listQuery.waybillCode" placeholder="面单号" clearable />
        </template>
      </vxe-table-column>
      <vxe-table-column>
        <vxe-table-column field="wavePickingCode" title="波次号" min-width="200" sortable />
        <template v-slot:header="{ column }">
          <el-input v-model="listQuery.wavePickingCode" placeholder="请输入波次号" clearable />
        </template>
      </vxe-table-column>
      <vxe-table-column>
        <vxe-table-column field="code" title="发货单号" min-width="200" sortable show-header-overflow show-overflow/>
        <template v-slot:header="{ column }">
          <el-input v-model="listQuery.code" placeholder="请输入发货单号" clearable/>
        </template>
      </vxe-table-column>
      <vxe-table-column>
        <vxe-table-column field="sourceCode" title="来源单号" min-width="200" sortable/>
        <template v-slot:header="{ column }">
          <el-input v-model="listQuery.sourceCode" placeholder="请输入来源单号" clearable/>
        </template>
      </vxe-table-column>
      <vxe-table-column>
        <vxe-table-column field="typeText" title="单据类型" min-width="200" />
        <template v-slot:header="{ column }">
          <el-select v-model="listQuery.type" placeholder="请选择单据类型" clearable>
            <el-option
              v-for="item in typeList"
              :key="item.code"
              :label="item.name"
              :value="item.code"
            />
          </el-select>
        </template>
      </vxe-table-column>


      <vxe-table-column>
        <vxe-table-column field="totalNum" title="订单数量" min-width="200" sortable/>
        <template v-slot:header="{ column }">
          <el-input v-model="listQuery.totalNumStart" placeholder="下限" type='number' style="width:45%;"/>
          -
          <el-input v-model="listQuery.totalNumEnd" placeholder="上限" type='number' style="width:45%;"/>
        </template>
      </vxe-table-column>
      <vxe-table-column>
        <vxe-table-column field="distributionNum" title="分配数量" min-width="200" sortable/>
        <template v-slot:header="{ column }">
          <el-input v-model="listQuery.distributionNumStart" placeholder="下限" type='number' style="width:45%;"/>
          -
          <el-input v-model="listQuery.distributionNumEnd" placeholder="上限" type='number' style="width:45%;"/>
        </template>
      </vxe-table-column>
      <vxe-table-column>
        <vxe-table-column field="pickNum" title="拣货数量" min-width="200" sortable/>
        <template v-slot:header="{ column }">
          <el-input v-model="listQuery.pickNumStart" placeholder="下限" :min="0" :max="listQuery.pickNumStart" type='number' style="width:45%;"/>
          -
          <el-input v-model="listQuery.pickNumEnd" placeholder="上限" :min="listQuery.pickNumEnd" type='number' style="width:45%;"/>
        </template>
      </vxe-table-column>
      <vxe-table-column>
        <vxe-table-column field="sendNum" title="出库数量" min-width="200" sortable/>
        <template v-slot:header="{ column }">
          <el-input v-model="listQuery.sendNumStart" placeholder="下限" type='number' style="width:45%;"/>
          -
          <el-input v-model="listQuery.sendNumEnd" placeholder="上限" type='number' style="width:45%;"/>
        </template>
      </vxe-table-column>
      <vxe-table-column>
        <vxe-table-column field="receiverName" title="收货人" min-width="150" sortable/>
        <template v-slot:header="{ column }">
          <el-input v-model="listQuery.receiverName" placeholder="请输入收货人" clearable/>
        </template>
      </vxe-table-column>
      <vxe-table-column>
        <vxe-table-column field="receiverMobile" title="手机号" min-width="150" sortable/>
        <template v-slot:header="{ column }">
          <el-input v-model="listQuery.receiverMobile" placeholder="请输入手机号" clearable/>
        </template>
      </vxe-table-column>
      <vxe-table-column>
        <vxe-table-column field="receiverDetailAddress" title="收货地址" show-overflow min-width="620" sortable/>
        <template v-slot:header="{ column }">
          <el-input v-model="listQuery.receiverDetailAddress" placeholder="请输入收货地址" clearable/>
        </template>
      </vxe-table-column>
      <vxe-table-column>
        <vxe-table-column field="createdName" title="创建人" min-width="150" sortable/>
        <template v-slot:header="{ column }">
          <el-input v-model="listQuery.createdName" placeholder="请输入创建人" clearable/>
        </template>
      </vxe-table-column>
      <vxe-table-column>
        <vxe-table-column
          field="gmtCreated"
          show-header-overflow
          show-overflow
          title="创建时间"
          min-width="420"
          sortable
          :resizable="false"
        />
        <template v-slot:header>
          <el-date-picker
            v-model="gmtCreatedRange"
            type="daterange"
            value-format="yyyy-MM-dd"
            :picker-options="pickerOptions"
            style="width:100%"
            range-separator="至"
            start-placeholder="开始日期"
            end-placeholder="结束日期"
            @change="value => changeDate(value, 'gmtCreated')"
          />
        </template>
      </vxe-table-column>
      <vxe-table-column>
        <vxe-table-column field="modifiedName" title="修改人" min-width="150" sortable/>
        <template v-slot:header="{ column }">
          <el-input v-model="listQuery.modifiedName" placeholder="请输入修改人" clearable/>
        </template>
      </vxe-table-column>
      <vxe-table-column>
        <vxe-table-column
          field="gmtModified"
          show-header-overflow
          show-overflow
          title="修改时间"
          min-width="420"
          sortable
          :resizable="false"
        />
        <template v-slot:header>
          <el-date-picker
            v-model="gmtModifiedRange"
            type="daterange"
            value-format="yyyy-MM-dd"
            :picker-options="pickerOptions"
            style="width:100%"
            range-separator="至"

            start-placeholder="开始日期"
            end-placeholder="结束日期"
            @change="value => changeDate(value, 'gmtModified')"
          />
        </template>
      </vxe-table-column>
      <vxe-table-column title="操作" fixed="right" min-width="200">
        <template slot-scope="scope">
          <el-tooltip  effect="dark" content="修改" placement="top" v-if="scope.row.status == '0'">
            <vxe-button type="text" @click="funcEdit(scope.row.code, scope.row.type)">
              <i class="el-icon-edit"/>
            </vxe-button>
          </el-tooltip>
          <el-tooltip  effect="dark" content="分配完成" placement="top"
                      v-if="scope.row.status == '1' || scope.row.status == '2'">
            <vxe-button type="text" @click="allocationComplete(scope.row.code)">
              <i class="iconfont icon-wancheng"/>
            </vxe-button>
          </el-tooltip>
          <el-tooltip  effect="dark" content="库存分配" placement="top"
                      v-if="scope.row.status == '1' || scope.row.status == '2'">
            <vxe-button type="text" @click="funcDistribution(scope.row.code)">
              <i class="iconfont iconkucuntiaozheng"/>
            </vxe-button>
          </el-tooltip>
          <el-tooltip  effect="dark" content="取消分配" placement="top"
                      v-if="scope.row.status == '2' || scope.row.status == '3' ">
            <vxe-button type="text" @click="funcOnReceive(scope.row.code)">
              <i i class="iconfont iconkucuntiaozheng1"></i>
            </vxe-button>
          </el-tooltip>
          <el-tooltip  effect="dark" content="作废" placement="top" v-if="scope.row.status == '0'">
            <vxe-button type="text" @click="funcBlank(scope.row.code)">
              <i class="el-icon-document-delete"/>
            </vxe-button>
          </el-tooltip>
          <!-- <el-tooltip  effect="dark" content="获取面单" placement="top"
            v-if="scope.row.status === '9' && scope.row.sourceType === 'qimen'"
          >
            <vxe-button type="text" @click="getFaceSheet(scope.row.code)">
              <i class="iconfont2 icon-huoqumiandanxinxi" />
            </vxe-button>
          </el-tooltip> -->
          <el-tooltip  effect="dark" content="查看" placement="top">
            <vxe-button type="text" @click="funcDetail(scope.row.code, scope.row.type)">
              <i class="el-icon-document"/>
            </vxe-button>
          </el-tooltip>
        </template>
      </vxe-table-column>
    </vxe-table>
    <vxe-pager
      :loading="loading"
      :current-page.sync="listQuery.pageNum"
      :page-size.sync="listQuery.pageSize"
      :total="listQuery.total"
      :layouts="['PrevJump', 'PrevPage', 'Number', 'NextPage', 'NextJump', 'Sizes', 'FullJump', 'Total']"
      @page-change="handlePageChange"
    />
    <vxe-modal v-model="modelUploadFlag" title="导入" width="1300" height="900" destroy-on-close>
      <dataImport type="deliveryList" @importFileSuccess="importFileSuccess" />
    </vxe-modal>
    <vxe-modal v-model="printExpressBillmodel" title="打印面单" width="600" height="600" destroy-on-close>
      <printFaceSheet :printData="printData" :parcelType="parcelType" @finshPrint="findList();openClosePrintMode()" />
    </vxe-modal>
  </div>
</template>
<script>
  import Vue from 'vue'
  import 'xe-utils'
  import VXETable from 'vxe-table'
  import 'vxe-table/lib/index.css'
  import XEUtils from 'xe-utils'
  import VXEUtils from 'vxe-utils'

  import dataImport from '@/views/components/importFile'
  import printFaceSheet from '@/components/Printing'
  Vue.use(VXETable, VXEUtils, XEUtils, { mounts: ['cookie'] })
 import { getWarehouse, exportTask} from '@/api/basicInfo'
  import {
    deliveryCancelList,
    deliveryCancelHandler,
    deliveryBlank,
    allocationCompleted,
    getWaybillCode,
    shipments,
    carrierDropdown
  } from '@/api/outStorage'
  import '@/assets/iconfont/iconfont.css'
  import soonPrint from '@/components/Printing/printBefore.js'
  export default {
    name: 'CancelOrder',
    components: {
      dataImport,
      printFaceSheet
    },
  computed: {
    printFlag: function () {
      if (this.initFinishFlag) {
        let selectRecords = this.$refs.xTable.getCheckboxRecords();
        if (selectRecords.length > 0) {
          return false;
        } else {
          return true;
        }
      }
      return true;
    },
  },
    data() {
      return {
        disabledBtn: true, // 生成拣货单、打印面单 按钮
        message: '',
        // 日期选项
        pickerOptions: {
          shortcuts: [{
            text: '最近一周',
            onClick(picker) {
              const end = new Date()
              const start = new Date()
              start.setTime(start.getTime() - 3600 * 1000 * 24 * 7)
              picker.$emit('pick', [start, end])
            }
          }, {
            text: '最近一个月',
            onClick(picker) {
              const end = new Date()
              const start = new Date()
              start.setTime(start.getTime() - 3600 * 1000 * 24 * 30)
              picker.$emit('pick', [start, end])
            }
          }, {
            text: '最近三个月',
            onClick(picker) {
              const end = new Date()
              const start = new Date()
              start.setTime(start.getTime() - 3600 * 1000 * 24 * 90)
              picker.$emit('pick', [start, end])
            }
          }]
        },
        warehouseData: [],
        loading: false,
        exportAllloading: false,
        allAlign: 'center',
        tableData: [],
        modelUploadFlag: false,
        modelAddFlag: false,
        modelEditFlag: false,
        modelDetailFlag: false,
        modelPrintFlag: false,
        initFinishFlag: false,
        gmtCreatedRange: '',
        gmtModifiedRange: '',
        typeList: [
          { code: '0', name: '销售出库' },
          { code: '1', name: '报损出库' },
          { code: '2', name: '领用出库' },
          { code: '3', name: '盘亏出库' },
          { code: '4', name: '采购退货' },
          { code: '5', name: '调拨退货' },
        ],
        copy: false,
        listQuery: {
          isCancel: 1,
          total: 0,             //总数
          createdByName: '',         //创建人
          modifiedByName: '',        //修改人
          gmtCreated: '',        //创建时间
          gmtModified: '',       //修改时间
          code: '',                              //全局code ,
          createdByText: '',                     //创建人描述 ,
          deliveryCode: '',                      //出货单号 ,
          distributionNum: '',                   //分配数量 ,
          modifiedByText: '',                    //修改人描述 ,
          pickNum: '',                           //分拣数量 ,
          remarks: '',                           //备注 ,
          sendNum: '',                           //发货数量 ,
          shipmentCode: '',                      //入驻商 ,
          shipmentName: '',                      //入驻商名称 ,
          sourceCode: '',                        //来源单号 ,
          statusText: '',                        //状态描述 ,
          totalNum: '',                          //总数量 ,
          type: '',                              //单据类型 ,
          typeText: '',                          //单据类型描述 ,
          warehouseCode: '',                     //仓库 ,
          warehouseName: '',                     //仓库名称
          wavePickingCode:"",
          pageNum: 1,
          pageSize: 10,
          sortField: 'id',
          sortType: 'desc',
          totalNumStart: '',
          distributionNumStart: '',
          pickNumStart: '',
          sendNumStart: '',
          totalNumEnd: '',
          distributionNumEnd: '',
          pickNumEnd: '',
          sendNumEnd: '',
          carrierName:'',
          remarks:'',
          socket: null
        },
        prepackagedList: [
          { value: '0', label: '否' },
          { value: '1', label: '是' }
        ],
        invoiceData: [], // 要打印的发货单数据
        parcelType: '', // 哪家快递
        printData: [], // 要打印的面单数据
        printExpressBillmodel: false, //打印机组件
        generatePicking: true , // 生成拣货单按钮状态
        options: [],
        carrierList: []
      }
    },
    created() {
      this.getWarehouse()
      this.$eventBus.$on("refreshList", () => {
        this.findList()
      })
      window.onstorage = ({key}) => {
        if (key.indexOf('printComplete') != -1) {
          this.$message.success('打印任务执行完毕~')
          this.findList()
          this.$refs.xTable.clearCheckboxRow()
          localStorage.removeItem(key)
        }
      }
    },
    methods: {
      upload() {
        this.modelUploadFlag = true;
      },
      // 增加组件的父方法
      importFileSuccess() {
        this.modelUploadFlag = false;
        this.findList();
      },

      //仓库查询
      getWarehouse() {
        getWarehouse().then(response => {
          this.warehouseData = response.data
          this.findList()
          this.initFinishFlag = true;
        })
      },
      changeDate(value, prefix) {
        if (value) {
          this.listQuery[`${prefix}Start`] = value[0] + ' 00:00:00'
          this.listQuery[`${prefix}End`] = value[1] + ' 23:59:59'
        } else {
          this.listQuery[`${prefix}Start`] = ''
          this.listQuery[`${prefix}End`] = ''
        }
      },
    // 清空已选择的数据
    clearCheckboxRow () {
      this.disabledBtn = true
      this.$refs.xTable.clearCheckboxRow()
    },
    // 全选与否、部分勾选与否
    checkboxChangeEvent({selection}) {
      // 已作废的单子不能生成拣货单、打印面单
      if (selection.length === 0) {
        this.disabledBtn = true
      } else {
        const invalid = selection.filter(item => {return item.status === '4'})
        this.disabledBtn = invalid.length > 0
      }
    },
    openClosePrintMode() {
      this.printExpressBillmodel = !this.printExpressBillmodel
    },
    // 打印面单
    printExpressBill(personality) {
      let selectRecords = this.$refs.xTable.getCheckboxRecords();
      let expressType = []
      let arr = [];
      let oddNumbers = [];
      selectRecords.forEach((i) => {
        if (i.waybillCode && i.waybillCode !== '') {
          arr.push(i.code);
          expressType.push(i.logisticsCode);
        } else {
          let v = `单号${i.code}`
          oddNumbers.push(v)
        }
      });
      if (oddNumbers.length>0) {
        this.$message.error(`${oddNumbers.join('，')}，没有面单号！`)
        return false
      }
      if (expressType.length>0) {
        let arr = [...new Set(expressType)]
        if (arr.length>1) {
          this.$message.error('批量打印同时只能打印同一家快递！')
          return false
        }
      }
        localStorage.setItem('printCode', JSON.stringify(arr))
        let routeUrl = this.$router.resolve({
          path: '/printResult',
          query: {
            type: 'array',
            listInterface: 'printExpress'
          }
        })
        // window.open(routeUrl.href, '_blank')
        soonPrint(routeUrl.href)
    },
    printTest() {
      let printData = {"cmd":"print","requestID":"123458666","version":"1.0","task":{"taskID":"729666666","preview":true,"printer":"","notifyMode":"allInOne","previewType":"pdf","documents":[{"documentID":"012345678555","contents":[{"data":{"recipient":{"address":{"city":"杭州市","detail":"良睦路999号乐佳国际大厦2号楼小邮局","district":"余杭区","province":"浙江省","town":""},"mobile":"13012345678","name":"菜鸟网络","phone":"057112345678"},"routingInfo":{"routeCode":"123A-456-789"},"sender":{"address":{"city":"杭州市","detail":"文一西路1001号阿里巴巴淘宝城5号小邮局","district":"余杭区","province":"浙江省","town":""},"mobile":"13012345678","name":"阿里巴巴","phone":"057112345678"},"waybillCode":"0123456999"},"templateURL":"http://cloudprint.cainiao.com/template/standard/290659/44"},{"templateURL":"http://cloudprint.cainiao.com/template/customArea/13450842/4"}]}]}}
      if (!this.socket) {
        this.socket = new socketClient({
          url: 'ws://localhost:13528',
          received: function(data) {
            // 监听服务器返回信息
            console.log('received--->', data)
          }
        })
      }
      this.socket.sendCommand(printData)
    },
    // 取消订单处理
    cancelOrderHandler(){
      const rLoading = this.openLoading({
        text: '处理中...',
        duration: 'x'
      })
      deliveryCancelHandler().then(res => {
        this.$message.success(res.msg)
      }).finally(()=>{
        this.findList()
        rLoading.close();
      })
    },
      //获取列表
      findList() {
        this.clearCheckboxRow()
        this.loading = true
        shipments().then(res => {
          this.options = res.data
        })
        carrierDropdown().then(res => {
        this.carrierList = res.data
      })
        return deliveryCancelList(this.listQuery).then(response => {
          this.tableData = response.data.records
          for (let i = 0; i < this.tableData.length; i++) {
            this.tableData[i].receiverDetailAddress = this.tableData[i].receiverDetailAddress
          }
          this.listQuery.total = response.data.total
          this.loading = false
        })
      },
      // 排序
      sortList({ column, property, order }) {
        if (order) {
          this.listQuery.sortField = property
          this.listQuery.sortType = order
        } else {
          this.listQuery.sortField = ''
        }
        this.findList()
      },
      // 编辑
      funcEdit(code, type) {
        if(type == 4){
          this.$router.push({
            path: "/wms/returnEdit",
            query: { code: code,}
          });
        }else{
          this.$router.push({
            path: "/wms/deliveryEdit",
            query: { code: code,}
          });
        }
      },
      // 详情方法
      funcDetail(code,type) {
        this.$router.push({
          path: '/wms/deliveryDetail',
          query: { code: code, type:type }
        })
      },
      // 公共取消
      fatherCancel(modelFlag) {
        switch (modelFlag) {
          case 'add':
            this.modelAddFlag = false
            break
          case 'edit':
            this.modelEditFlag = false
            break
          case 'detail':
            this.modelDetailFlag = false
            break
          default:
        }
      },
      // 分页handle
      handlePageChange({ currentPage, pageSize }) {
        this.listQuery.pageNum = currentPage
        this.listQuery.pageSize = pageSize
        this.findList()
      },
      // 底部颜色设置
      /*  footerCellClassName({ $rowIndex, column, columnIndex }) {
         if (columnIndex === 0) {
           if ($rowIndex === 0) {
             return 'col-blue'
           } else {
             return 'col-red'
           }
         }
       }, */
      // 分配完成
      allocationComplete(data) {
        let that = this
        this.$confirm('当前订单还有商品未分配，是否确认完结？', '提示', {
          type: 'warning'
        }).then(() => {
          allocationCompleted(data).then(response => {
              that.$message({ message: response.msg, type: 'success' })
              that.findList()
          }).catch(() => {
              // that.$message({ message: '请重试！', type: 'error' })
              that.findList()
          })
        })
      },
      // 收货
      funcDistribution(code) {
        this.$router.push({
          path: '/wms/distribution',
          query: { code: code }
        })
      },
      // 取消收货
      funcOnReceive(code) {
        this.$router.push({
          path: '/wms/deliveryCancel',
          query: { code: code }
        })
      },

      //作废
      funcBlank(code) {
        this.$confirm('确认作废吗？').then(_ => {
          deliveryBlank(code).then(response => {
            this.$message({ message: response.msg, type: 'success' })
            this.findList()
          })
        })
      },
      // 获取面单
      getFaceSheet(code) {
        this.$confirm('确认要获取面单吗？', '提示', {
          type: 'info'
        }).then(() => {
          const loading = this.$loading({
            lock: true,
            text: '获取面单中...',
            spinner: 'el-icon-loading',
            background: 'rgba(0, 0, 0, 0.7)'
          });
          getWaybillCode(code).then(res => {
            if (res.status === 0) {
              this.$message({ message: res.msg, type: 'success' })
              this.findList()
            } else {
              this.$message.error(res.msg)
            }
          }).finally(()=>{
            loading.close();
          })
        })
      },
        // 导出全部
      AllDataEventAll () {
        let params = {
        dataType: 'DELIVERY',
          filter: this.listQuery
        }
        exportTask(params).then(data => {
          this.$message.success(data.msg)
        })
      },
      // 翻译是否预打包状态
      formatterPackaged({cellValue}) {
        if (cellValue == '0') {
          return '否'
        }
        if (cellValue == '1') {
          return '是'
        }
      },
      // 设置底部合计
      footerMethod({ columns, data }) {
        return [
          columns.map((column, columnIndex) => {
            if (columnIndex === 0) {
              return '合计'
            }
            if (['pageviews', 'forecast'].includes(column.property)) {
              return XEUtils.sum(data, column.property)
            }
            return null
          })
        ]
      }
    },
    destroyed() {
      this.$eventBus.$off('refreshList')
    },
  }
</script>

<style>
  .vxe-table .vxe-body--column:not(.col--ellipsis), .vxe-table .vxe-footer--column:not(.col--ellipsis), .vxe-table .vxe-header--column:not(.col--ellipsis) {
    padding: 6px 0;
  }

  .vxe-toolbar {
    padding: 0 0 10px 0
  }
  .btn-group {
    margin: 0 8px 2px 8px
  }
</style>
